package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.QueryGoodsDetailEvaluationBase;
import com.scsj.supermarket.bean.GoodsDetailEvaluationBean;
import com.scsj.supermarket.model.QueryGoodsDetailEvaluationModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2018/6/25.
 */

public class QueryGoodsDetailEvaluationPresenter extends BasePresenter implements QueryGoodsDetailEvaluationBase.IPresenter{


    private QueryGoodsDetailEvaluationBase.IView mView;
    private QueryGoodsDetailEvaluationBase.IModel mModel;

    public QueryGoodsDetailEvaluationPresenter(QueryGoodsDetailEvaluationBase.IView mView) {
        this.mView = mView;
        mModel = new QueryGoodsDetailEvaluationModel();
    }

    @Override
    public void deliverData(RequestBody requestBody) {

            addSubscription(mModel.getData(requestBody, new ResponseCallback<GoodsDetailEvaluationBean>() {
                @Override
                public void onSuccess(GoodsDetailEvaluationBean result) {

                    if (result.isSuccess()) {
                        mView.showSuccessMsg("获取成功",result);
                        Logger.e("获取成功" + result.toString());
                    } else {
                        mView.showErrorMsg(result.getMsg());
                        Logger.e("未成功" + result.toString());
                    }
                }

                @Override
                public void onFaild(String msg) {
                    mView.showErrorMsg(msg);
                    Log.e("失败", msg + "");
                }
            }));
        }


}
